package cn.com.io.stream;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created by Administrator on 2015/12/9.
 */
public class FileReaderTest {
    public static void main(String[] args) throws IOException {
        FileReader reader = null;

        try {
            reader = new FileReader(new File(System.getProperty("user.dir") + "\\src\\cn\\com\\io\\stream\\FileInputStreamTest.java"));//创建字符输入流
            char[] buf = new char[32];//创建一个长度为32的数组，用来存储读取到的数据
            int hasRead = 0;
            int i=1;
            while ((hasRead = reader.read(buf)) > 0) {
                System.out.println(new String(buf, 0, hasRead));//将字符数组转换成字符串输入
                System.out.println("------------"+i+++"-------------");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                reader.close();
            }
        }

    }
}
